import Vue from 'vue';
import Vuex from 'vuex';
import { state } from './state'
import { getters } from './getters'
import actions from './actions'
Vue.use(Vuex);

export default new Vuex.Store({
  state,
  getters,
  mutations: {
    SET_TITLE: (state, payload) => {state.base_title = payload},
    LOGOUT: (state) => {
      state.isLogin = false;
      localStorage.removeItem('usr')
      state.userInfo = {}
    },
    LOGIN: (state, payload) => {
      state.isLogin = true; 
      state.userInfo = payload;
      localStorage.setItem('usr',JSON.stringify(state.userInfo))
    },
    SET_USER: (state, payload) => {state.userInfo = payload}
  },
  actions,
});
